<?php

namespace App\Console\Commands;


use BestSign\Requests\RegisterUserClient;
use Guangda\Client;
use Guangda\Transfer;
use Hangxin\CommonClient;
use Hangxin\OrderClient;
use Hangxin\PersonClient;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Modules\Common\Models\BestsignPeople;
use Modules\Common\Models\Branch;
use Modules\Common\Models\EmployeeBank;
use Modules\Common\Models\EmployeeUser;
use Modules\Common\Models\EmployeeWithdraw;
use Modules\Common\Models\Enterprise;
use Modules\Common\Models\GuangdaBank;
use Modules\Common\Models\SuperEnterpriseUser;
use Modules\Common\Models\SuperEnterpriseUserAccount;
use Modules\Common\Models\Task;
use Modules\Common\Models\TaskCheckApplyDesc;
use Modules\Common\Models\Trade;
use Modules\Common\Models\Validation\EmployeeUserValidation;
use Modules\Common\Util\Database;
use Illuminate\Support\Facades\DB;
use Modules\Wechat\Http\Controllers\Employee\Business\Contracts\Contract3;
use Modules\Wechat\Http\Controllers\Employee\Business\RegisterUserUtil;
use Modules\Wechat\Http\Controllers\Employee\Business\SignContractUtil;
use Modules\Common\Models\BestsignBranch;
use Modules\Common\Models\Employee;
use Modules\Common\Models\SettlementDetail;
use Illuminate\Support\Facades\Mail;
use Modules\Common\Business\Core\Elm\ElmWorker;
use Modules\Common\Models\District;
use Modules\Common\Models\EmployeeInvoice;
use Modules\Common\Models\Project;
use Modules\Common\Util\Api;
use Modules\Common\Models\TradeInvoice;


class Run extends Command
{
    protected $signature = 'run';
    protected $description = '执行脚本';

    public function handle()
    {

        $this->hideUser('18856851679');

    }


  
    protected function hideUser($mobile)
    {
        if (config('app.debug')) {
            DB::transaction(function () use ($mobile) {
                $employeeUser = EmployeeUser::where('mobile', $mobile)->first();
                $employee = $employeeUser->employee;
                $bestsignPeople = BestsignPeople::where('employee_user_id', $employeeUser->id)->first();
                $employeeUser->mobile = 'fake:' . Str::random(6);
                $employeeUser->open_id = Str::random(32);
                $employeeUser->union_id = Str::random(32);
                $employeeUser->save();
                $employee->id_card_no = 'fake:' . Str::random(13);
                $employee->save();
                $bestsignPeople->identity = $employee->id_card_no;
                $bestsignPeople->account = $employeeUser->mobile;
                $bestsignPeople->save();
            });
        } else {
            throw new \Exception('仅测试环境可用');
        }


    }


}


